<template>
    <div id="parts">
        <div class="operation">
            <el-button v-if="menuId==='4641'" @click="insertList" class="slot-btn-top" type="primary" size="small">
                发放任务
            </el-button>
        </div>
        <el-table :data="dataList.slice((currentPage-1)*pagesize,currentPage*pagesize)" :highlight-current-row="true" stripe border class="table-index" :height="tableHeight" style="width: 100%;" :header-cell-style="getRowClass">
            <el-table-column fixed type="index" label="*" sortable min-width="40"></el-table-column>
            <el-table-column prop="batchnums" label="清洗批号" sortable min-width="160"></el-table-column>
            <el-table-column prop="resourcename" label="清洗物料名称" sortable min-width="160"></el-table-column>
            <el-table-column prop="taskperformpersonName" label="清洗执行人" sortable min-width="120"></el-table-column>
            <el-table-column prop="taskreleaseaddtime" label="清洗计划完成时间" sortable min-width="160"></el-table-column>
            <el-table-column prop="istaskstart" label="清洗是否接收" :formatter="formatNeedTrain" sortable min-width="140"></el-table-column>
            <el-table-column prop="taskbegintime" label="清洗实际开工时间" sortable min-width="160"></el-table-column>
            <el-table-column prop="tasknums" label="计划清洗数量" sortable min-width="130"></el-table-column>
            <el-table-column prop="actualcompletenums" label="实际清洗数量" sortable min-width="130"></el-table-column>
            <el-table-column prop="taskendtime" label="清洗实际完工时间" sortable min-width="160"></el-table-column>
            <el-table-column prop="istaskend" label="清洗是否完工" :formatter="formatNeedTrain" sortable min-width="130"></el-table-column>
            <el-table-column prop="taskendaddtime" label="清洗完工创建时间" sortable min-width="160"></el-table-column>
            <el-table-column fixed="right" label="操作" sortable align="center" width="75">
                <template slot-scope="scope">
                    <el-button @click="updateList(scope.row)" type="text" size="small">编辑</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
                       :current-page="currentPage" :page-sizes="[5,10, 15,20, 25,30,50, 100]" :page-size="pagesize"
                       layout="total, sizes, prev, pager, next, jumper" :total="dataList.length"></el-pagination>

        <!-- 详情信息 -->
        <el-dialog :title="dialogTitle" width="90%" top="30px" :visible.sync="isDialog" :close-on-click-modal="false">
            <el-tabs v-model="activeName" @tab-click="handleClick" style="padding-bottom: 15px;">
                <el-tab-pane label="任务信息" name="1" class="dialog1" :style="dialogHeightPane">
                    <h3 class="dialog-plate-title"><span>基本信息</span></h3>
                    <el-form :inline="true" class="demo-form-inline" v-model="dialogList" label-position="right" label-width="180px">
                        <el-form-item label="流水号"><el-input v-model="dialogList.taskcode" :disabled="!dialogListDisabled.taskcode"></el-input></el-form-item>
                        <el-form-item label="清洗批号"><el-input v-model="dialogList.batchnums" :disabled="!dialogListDisabled.batchnums"></el-input></el-form-item>
                        <el-form-item label="清洗物料名称"><el-input v-model="dialogList.resourcename"
                                      :disabled="!dialogListDisabled.resourcename"></el-input></el-form-item>
                        <el-form-item label="物料规格型号"><el-input v-model="dialogList.typenums" :disabled="!dialogListDisabled.typenums"></el-input></el-form-item>
                        <el-form-item label="清洗业务类型"><el-input v-model="dialogList.businesstype"
                                      :disabled="!dialogListDisabled.businesstype"></el-input></el-form-item>
                        <el-form-item label="清洗计划编制人"><el-input v-model="dialogList.taskreleasepersonName"
                                      :disabled="!dialogListDisabled.taskreleasepersonName"></el-input></el-form-item>
                        <el-form-item label="计划创建时间"><el-input v-model="dialogList.taskreleaseaddtime"
                                      :disabled="!dialogListDisabled.taskreleaseaddtime"></el-input></el-form-item>
                        <el-form-item label="清洗执行人"><el-select v-model="dialogList.taskperformperson"
                                       :disabled="!dialogListDisabled.taskperformperson">
                                <el-option v-for="item in performName" :key="item.id" :label="item.name"
                                           :value="item.id"></el-option>
                            </el-select></el-form-item>
                        <el-form-item label="清洗计划完成时间"><el-date-picker v-model="dialogList.taskstartorendtime"
                                            :disabled="!dialogListDisabled.taskstartorendtime"
                                            format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间"
                                            style="width: 200px;"></el-date-picker></el-form-item>
                        <el-form-item label="计划创建类型"><el-select v-model="dialogList.tasktype" :disabled="!dialogListDisabled.tasktype">
                                <el-option :value="1" label="计划任务"></el-option>
                                <el-option :value="2" label="临时任务"></el-option>
                            </el-select></el-form-item>
                    </el-form>

                    <h3 class="dialog-plate-title"><span>待办信息</span></h3>
                    <el-form :inline="true" class="demo-form-inline" v-model="dialogList" label-position="right"
                             label-width="180px">
                        <el-form-item label="任务是否接收">
                            <el-select v-model="dialogList.istaskstart" :disabled="!dialogListDisabled.istaskstart">
                                <el-option label="否" value="0"></el-option>
                                <el-option label="是" value="1"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="接收创建时间">
                            <el-date-picker v-model="dialogList.taskstartaddtime"
                                            :disabled="!dialogListDisabled.taskstartaddtime"
                                            format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间"
                                            style="width: 200px;"></el-date-picker>
                        </el-form-item>
                    </el-form>

                    <h3 class="dialog-plate-title"><span>进行中信息</span></h3>
                    <el-form :inline="true" class="demo-form-inline" v-model="dialogList" label-position="right" label-width="180px">
                        <el-form-item label="清洗是否开工">
                            <el-select v-model="dialogList.istaskbegin" :disabled="!dialogListDisabled.istaskbegin">
                                <el-option label="否" value="0"></el-option>
                                <el-option label="是" value="1"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="清洗实际开工时间">
                            <el-date-picker v-model="dialogList.taskbegintime"
                                            :disabled="!dialogListDisabled.taskbegintime" format="yyyy-MM-dd HH:mm:ss"
                                            type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="清洗开工创建时间">
                            <el-date-picker v-model="dialogList.taskbeginaddtime"
                                            :disabled="!dialogListDisabled.taskbeginaddtime"
                                            format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间"
                                            style="width: 200px;"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="计划清洗数量">
                            <el-input v-model="dialogList.tasknums" :disabled="!dialogListDisabled.tasknums"></el-input>
                        </el-form-item>
                        <el-form-item label="实际清洗数量">
                            <el-input v-model="dialogList.actualcompletenums"
                                      :disabled="!dialogListDisabled.actualcompletenums"></el-input>
                        </el-form-item>
                        <el-form-item label="清洗是否结束">
                            <el-select v-model="dialogList.istaskend" :disabled="!dialogListDisabled.istaskend">
                                <el-option label="否" value="0"></el-option>
                                <el-option label="是" value="1"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="清洗实际结束时间">
                            <el-date-picker v-model="dialogList.taskendtime" :disabled="!dialogListDisabled.taskendtime"
                                            format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间"
                                            style="width: 200px;"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="清洗结束创建时间">
                            <el-date-picker v-model="dialogList.taskendaddtime"
                                            :disabled="!dialogListDisabled.taskendaddtime" format="yyyy-MM-dd HH:mm:ss"
                                            type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker>
                        </el-form-item>
                    </el-form>

                    <h3 class="dialog-plate-title"><span>复核信息</span></h3>
                    <el-form :inline="true" class="demo-form-inline" v-model="dialogList" label-position="right"
                             label-width="180px">
                        <el-form-item label="任务是否复核">
                            <el-select v-model="dialogList.isreviewtask" :disabled="!dialogListDisabled.isreviewtask">
                                <el-option label="否" value="0"></el-option>
                                <el-option label="是" value="1"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="复核执行人">
                            <el-input v-model="dialogList.reviewpersonName"
                                      :disabled="!dialogListDisabled.reviewpersonName"></el-input>
                        </el-form-item>
                        <el-form-item label="复核结果状态">
                            <el-select v-model="dialogList.reviewresult" :disabled="!dialogListDisabled.reviewresult">
                                <el-option label="[空]" value="-1"></el-option>
                                <el-option label="正常" value="1"></el-option>
                                <el-option label="异常" value="0"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="复核时间">
                            <el-date-picker v-model="dialogList.reviewtime" :disabled="!dialogListDisabled.reviewtime"
                                            format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间"
                                            style="width: 200px;"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="复核创建时间">
                            <el-date-picker v-model="dialogList.reviewaddtime"
                                            :disabled="!dialogListDisabled.reviewaddtime" format="yyyy-MM-dd HH:mm:ss"
                                            type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker>
                        </el-form-item>
                    </el-form>
                    <div style="text-align: right">
                        <el-button @click="submitList" type="primary">确 定</el-button>
                    </div>
                </el-tab-pane>
                <el-tab-pane v-if="dialogType !== '1'" label="过程状态信息" name="2" :style="dialogHeightPane">
                    <el-button @click="insertProcessStateList" type="primary" size="small">新增</el-button>
                    <el-table :data="processStateData.slice((currentPage-1)*pagesize,currentPage*pagesize)" stripe border class="table-index" :height="dialogTableHeight" style="width: 100%;" :header-cell-style="getRowClass">
                        <el-table-column fixed type="index" label="*" sortable min-width="40"></el-table-column>
                        <el-table-column prop="detailname" label="工序名称" sortable min-width="150"></el-table-column>
                        <el-table-column prop="batchnums" label="清洗数量" sortable min-width="110"></el-table-column>
                        <el-table-column prop="typeName" label="清洗操作者" sortable min-width="120"></el-table-column>
                        <el-table-column prop="plannums" label="试剂名称" sortable min-width="120"></el-table-column>
                        <el-table-column prop="planunit" label="试剂批号" sortable min-width="120"></el-table-column>
                        <el-table-column prop="planboxnums" label="领用数量" sortable min-width="110"></el-table-column>
                        <el-table-column prop="customer" label="浸泡开始时间" sortable min-width="160"></el-table-column>
                        <el-table-column prop="begintime" label="浸泡结束时间" sortable min-width="160"></el-table-column>
                        <el-table-column fixed="right" label="操作" sortable align="center" width="75">
                            <template slot-scope="scope">
                                <el-button @click="updateProcessStateList(scope.row)" type="text" size="small">编辑
                                </el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
                                   :current-page="currentPage" :page-sizes="[5,10, 15,20, 25,30,50, 100]"
                                   :page-size="pagesize" layout="total, sizes, prev, pager, next, jumper"
                                   :total="processStateData.length"></el-pagination>
                </el-tab-pane>
                <el-tab-pane v-if="dialogType !== '1'" label="备注记录信息" name="3" :style="dialogHeightPane">
                    <el-button @click="insertNotesRecordList" type="primary" size="small">新增</el-button>
                    <el-table :data="notesRecordData.slice((currentPage-1)*pagesize,currentPage*pagesize)" stripe border
                              class="table-index" :height="dialogTableHeight" style="width: 100%;"
                              :header-cell-style="getRowClass">
                        <el-table-column fixed type="index" label="*" sortable min-width="40"></el-table-column>
                        <el-table-column prop="personName" label="填写人" sortable min-width="110"></el-table-column>
                        <el-table-column prop="type" label="类型" sortable min-width="110"></el-table-column>
                        <el-table-column prop="object" label="对象" sortable min-width="110"></el-table-column>
                        <el-table-column prop="time" label="填写时间" sortable min-width="160"></el-table-column>
                        <el-table-column prop="content" label="填写内容" sortable min-width="250"></el-table-column>
                        <el-table-column fixed="right" label="操作" sortable align="center" width="75">
                            <template slot-scope="scope">
                                <el-button @click="updateNotesRecordList(scope.row)" type="text" size="small">编辑
                                </el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
                                   :current-page="currentPage" :page-sizes="[5,10, 15,20, 25,30,50, 100]"
                                   :page-size="pagesize" layout="total, sizes, prev, pager, next, jumper"
                                   :total="notesRecordData.length"></el-pagination>

                </el-tab-pane>
            </el-tabs>
        </el-dialog>

        <!-- 过程状态信息 -->
        <el-dialog :title="dialogProcessStateTitle" width="900px" center :visible.sync="isProcessStateDialog" :close-on-click-modal="false" style="padding-bottom: 15px;">
            <el-form :inline="true" class="demo-form-inline" v-model="dialogProcessStateList" label-position="right" label-width="180px">

                <el-form-item label="工序名称"><el-input v-model="dialogProcessStateList.detailname"></el-input></el-form-item>

                <el-form-item label="清洗数量"><el-input v-model="dialogProcessStateList.batchnums"></el-input></el-form-item>

                <el-form-item label="清洗操作者"><el-select v-model="dialogProcessStateList.type" ><el-option v-for="item in processStateSelectUserData" :key="item.id" :value="item.id" :label="item.name"></el-option></el-select></el-form-item>
                <el-form-item label="试剂名称"><el-input v-model="dialogProcessStateList.plannums"></el-input></el-form-item>
                <el-form-item label="试剂批号"><el-input v-model="dialogProcessStateList.planunit"></el-input></el-form-item>
                <el-form-item label="领用数量"><el-input v-model="dialogProcessStateList.planboxnums"></el-input></el-form-item>
                <el-form-item label="浸泡开始时间"><el-date-picker v-model="dialogProcessStateList.customer" format="yyyy-MM-dd HH:mm:ss"
                                    type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker></el-form-item>
                <el-form-item label="浸泡结束时间"><el-date-picker v-model="dialogProcessStateList.begintime" format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker></el-form-item>
                <el-form-item label="清洗遍数"><el-input v-model="dialogProcessStateList.beginaddtime"></el-input></el-form-item>
                <el-form-item label="PH值检测"><el-input v-model="dialogProcessStateList.needer"></el-input></el-form-item>
                <el-form-item label="是否脱水"><el-select v-model="dialogProcessStateList.neednums">
                        <el-option value="0" label="否"></el-option>
                        <el-option value="1" label="是"></el-option>
                    </el-select></el-form-item>
                <el-form-item label="脱水设备是否正常"><el-select v-model="dialogProcessStateList.needunit">
                        <el-option value="0" label="否"></el-option>
                        <el-option value="1" label="是"></el-option>
                    </el-select></el-form-item>
                <el-form-item label="电表读数"><el-input v-model="dialogProcessStateList.elecmeter"></el-input></el-form-item>
                <el-form-item label="烘烤温度"><el-input v-model="dialogProcessStateList.needboxnums"></el-input></el-form-item>
                <el-form-item label="烘烤开始时间"><el-date-picker v-model="dialogProcessStateList.exceptionnums" format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker></el-form-item>
                <el-form-item label="烘烤结束时间"><el-date-picker v-model="dialogProcessStateList.exceptionunit" format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker></el-form-item>
                <el-form-item label="烘烤设备是否正常"><el-select v-model="dialogProcessStateList.exceptionboxnums">
                        <el-option value="0" label="否"></el-option>
                        <el-option value="1" label="是"></el-option>
                    </el-select></el-form-item>
                <el-form-item label="开始时间"><el-date-picker v-model="dialogProcessStateList.starttime" format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker></el-form-item>
                <el-form-item label="结束时间"><el-date-picker v-model="dialogProcessStateList.endtime" format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker></el-form-item>
                <el-form-item label="创建时间"><el-input v-model="dialogProcessStateList.overaddtime" disabled></el-input></el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer" style="text-align: right;">
                <el-button @click="submitProcessStateList" type="primary">确 定</el-button>
            </div>
        </el-dialog>

        <!-- 备注记录信息 -->
        <el-dialog :title="dialogNotesRecordTitle" width="600px" center :visible.sync="isNotesRecordDialog"
                   :close-on-click-modal="false" style="padding-bottom: 15px;">
            <el-form :inline="true" class="demo-form-inline" v-model="dialogNotesRecordList" label-position="right"
                     label-width="180px">
                <el-form-item label="填写人">
                    <el-input v-model="dialogNotesRecordList.personName" disabled></el-input>
                </el-form-item>
                <el-form-item label="填写时间">
                    <el-input v-model="dialogNotesRecordList.time" disabled></el-input>
                </el-form-item>
                <el-form-item label="类型">
                    <el-input v-model="dialogNotesRecordList.type"></el-input>
                </el-form-item>
                <el-form-item label="对象">
                    <el-input v-model="dialogNotesRecordList.object"></el-input>
                </el-form-item>
                <el-form-item label="填写内容">
                    <el-input type="textarea" :rows="8" v-model="dialogNotesRecordList.content"
                              style="width: 355px;"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer" style="text-align: right;">
                <el-button @click="submitNotesRecordList" type="primary">确 定</el-button>
            </div>
        </el-dialog>


    </div>
</template>

<script>
    export default {
        name: "",
        data() {
            let token = sessionStorage.getItem("tokenId");
            let menuId = sessionStorage.getItem('menuId');
            let tableHeight = menuId==='4641' ? (document.documentElement.clientHeight - 170) : (document.documentElement.clientHeight - 140);
            return {
                tokenId: token,
                menuId: menuId,
                currentPage: 1,
                pagesize: 10,
                activeName: '1',
                performName: [],
                tableHeight: tableHeight,
                dataList: [],

                //基本信息
                isDialog: false,
                dialogTitle: '',
                dialogType: '',
                dialogHeightPane: {
                    height: (document.documentElement.clientHeight - 180) + 'px',
                    overflowY: 'auto'
                },
                dialogTableHeight: document.documentElement.clientHeight - 260,
                dialogList: {
                    actualcompletenums: '',
                    batchnums: '',
                    businesstype: '',
                    isreviewtask: '',
                    istaskbegin: '',
                    istaskend: '',
                    istaskstart: '',
                    resourcename: '',
                    reviewaddtime: '',
                    reviewperson: '',
                    reviewpersonName: '',
                    reviewresult: '',
                    reviewtime: '',
                    taskbeginaddtime: '',
                    taskbegintime: '',
                    taskcode: '',
                    taskendaddtime: '',
                    taskendtime: '',
                    taskfinishstate: '',
                    tasknums: '',
                    taskperformperson: '',
                    taskperformpersonName: '',
                    taskreleaseaddtime: '',
                    taskreleaseperson: '',
                    taskreleasepersonName: '',
                    taskstartaddtime: '',
                    taskstartorendtime: '',
                    taskstate: '',
                    tasktype: '',
                    tid: '',
                    typenums: '',
                },
                dialogListDisabled: {
                    actualcompletenums: true,
                    batchnums: true,
                    businesstype: true,
                    isreviewtask: true,
                    istaskbegin: true,
                    istaskend: true,
                    istaskstart: true,
                    resourcename: true,
                    reviewaddtime: true,
                    reviewperson: true,
                    reviewpersonName: true,
                    reviewresult: true,
                    reviewtime: true,
                    taskbeginaddtime: true,
                    taskbegintime: true,
                    taskcode: true,
                    taskendaddtime: true,
                    taskendtime: true,
                    taskfinishstate: true,
                    tasknums: true,
                    taskperformperson: true,
                    taskperformpersonName: true,
                    taskreleaseaddtime: true,
                    taskreleaseperson: true,
                    taskreleasepersonName: true,
                    taskstartaddtime: true,
                    taskstartorendtime: true,
                    taskstate: true,
                    tasktype: true,
                    tid: true,
                    typenums: true,
                },

                //过程状态信息
                isProcessStateDialog: false,
                dialogProcessStateTitle: '',
                dialogProcessStateList: {
                    atoperator: '',
                    batchnums: '',
                    beginaddtime: '',
                    begintime: '',
                    customer: '',
                    detailname: '',
                    did: '',
                    endtime: '',
                    exceptionboxnums: '',
                    exceptionnums: '',
                    exceptionunit: '',
                    needboxnums: '',
                    needer: '',
                    neednums: '',
                    needunit: '',
                    overaddtime: '',
                    planboxnums: '',
                    plannums: '',
                    planunit: '',
                    starttime: '',
                    elecmeter:'',
                    tid: '',
                    type: '',
                    typeName: '',
                },
                processStateData: [],
                processStateSelectUserData: [],

                //备注记录信息
                dialogNotesRecordURL: {
                    getURL: '/api/adscm/operation/zzInalassemblyinfo/selectByTid/',
                    insertURL: '/api/adscm/operation/zzInalassemblyinfo/insert',
                    updateURL: '/api/adscm/operation/zzInalassemblyinfo/update',
                },
                isNotesRecordDialog: false,
                dialogNotesRecordTitle: '',
                dialogNotesRecordList: {
                    content: '',
                    id: '',
                    object: '',
                    person: '',
                    personName: '',
                    tid: '',
                    time: '',
                    type: '',
                },
                notesRecordData: [],
            };
        },
        created() {
            this.getData();
            this.getPerform();
        },
        methods: {
            getPerform() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/operation/qxClean/selectTaskPerformPerson?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.performName = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            getData() {
                let _this = this;
                let loading = this.$loading({
                    target: document.querySelector(".wrapper > .content-box"),
                    lock: true,
                    text: '正在努力加载中...',
                    spinner: 'el-icon-loading',
                    background: 'rgba(0, 0, 0, 0.8)'
                });
                let id;
                if (_this.menuId === '4641') {
                    id = '0/0/0';
                } else if (_this.menuId === '4642') {
                    id = '1/0/0';
                } else if (_this.menuId === '4643') {
                    id = '1/1/0';
                } else if (_this.menuId === '4644') {
                    id = '1/1/1';
                }
                this.$http({
                    url: '/api/adscm/operation/qxClean/selectQxClean/' + id + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.dataList = res.data.content;
                        loading.close();
                    } else {
                        _this.$message.error(res.data.desc);
                        loading.close();
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                    loading.close();
                })
            },
            insertList() {
                this.isDialog = true;
                this.dialogType = '1';
                this.dialogListDisabled = {
                    taskcode: false,
                    batchnums: true,
                    resourcename: true,
                    typenums: true,
                    businesstype: true,
                    taskreleaseperson: false,
                    taskreleasepersonName: false,
                    taskreleaseaddtime: false,
                    taskperformperson: true,
                    taskperformpersonName: true,
                    taskstartorendtime: true,
                    tasktype: true,
                    istaskstart: false,
                    taskstartaddtime: false,
                    istaskbegin: false,
                    taskbegintime: false,
                    taskbeginaddtime: false,
                    istaskend: false,
                    taskendtime: false,
                    taskendaddtime: false,
                    isoutstorage: true,
                    tasknums: true,
                    actualcompletenums: false,
                    isreviewtask: false,
                    reviewperson: false,
                    reviewpersonName: false,
                    reviewresult: false,
                    reviewtime: false,
                    reviewaddtime: false,
                    taskfinishstate: false,
                    taskstate: false,
                    tasksummingtype: false,
                    tid: true,
                };
                this.dialogList = {
                    actualcompletenums: '',
                    batchnums: '',
                    businesstype: '',
                    isreviewtask: '',
                    istaskbegin: '',
                    istaskend: '',
                    istaskstart: '',
                    resourcename: '',
                    reviewaddtime: '',
                    reviewperson: '',
                    reviewpersonName: '',
                    reviewresult: '',
                    reviewtime: '',
                    taskbeginaddtime: '',
                    taskbegintime: '',
                    taskcode: '',
                    taskendaddtime: '',
                    taskendtime: '',
                    taskfinishstate: '',
                    tasknums: '',
                    taskperformperson: '',
                    taskperformpersonName: '',
                    taskreleaseaddtime: '',
                    taskreleaseperson: '',
                    taskreleasepersonName: '',
                    taskstartaddtime: '',
                    taskstartorendtime: '',
                    taskstate: '',
                    tasktype: '',
                    tid: '',
                    typenums: '',
                };
            },
            updateList(row) {
                this.isDialog = true;
                this.dialogType = '2';
                this.activeName = '1';
                this.dialogListDisabled = {
                    taskcode: false,
                    batchnums: this.menuId === '4641' ? true : false,
                    resourcename: this.menuId === '4641' ? true : false,
                    typenums: this.menuId === '4641' ? true : false,
                    businesstype: this.menuId === '4641' ? true : false,
                    taskreleaseperson: false,
                    taskreleasepersonName: false,
                    taskreleaseaddtime: false,
                    taskperformperson: this.menuId === '4641' ? true : false,
                    taskperformpersonName: this.menuId === '4641' ? true : false,
                    taskstartorendtime: this.menuId === '4641' ? true : false,
                    tasktype: this.menuId === '4641' ? true : false,
                    istaskstart: this.menuId === '4641' ? true : false,
                    taskstartaddtime: false,
                    istaskbegin: this.menuId === '4642' ? true : false,
                    taskbegintime: this.menuId === '4642' ? true : false,
                    taskbeginaddtime: false,
                    istaskend: this.menuId === '4642' ? true : false,
                    taskendtime: this.menuId === '4642' ? true : false,
                    taskendaddtime: false,
                    isoutstorage: this.menuId === '4641' ? true : false,
                    tasknums: this.menuId === '4641' ? true : false,
                    actualcompletenums: this.menuId === '4642' ? true : false,
                    isreviewtask: this.menuId === '4643' ? true : false,
                    reviewperson: false,
                    reviewpersonName: false,
                    reviewresult: this.menuId === '4643' ? true : false,
                    reviewtime: this.menuId === '4643' ? true : false,
                    reviewaddtime: false,
                    taskfinishstate: false,
                    taskstate: false,
                    tasksummingtype: false,
                    tid: true,
                };
                this.dialogList = row;
                this.dialogList.taskperformperson = parseInt(this.dialogList.taskperformperson);
            },
            submitList() {
                let _this = this;
                let url;
                if (_this.dialogType === '1') {
                    url = '/api/adscm/operation/qxClean/insert?tokenId=' + _this.tokenId;
                } else if (_this.dialogType === '2') {
                    url = '/api/adscm/operation/qxClean/update?tokenId=' + _this.tokenId;
                }
                _this.dialogList.taskstartorendtime = _this.timestampToTime(_this.dialogList.taskstartorendtime);
                _this.dialogList.taskbegintime = _this.timestampToTime(_this.dialogList.taskbegintime);
                _this.dialogList.taskendtime = _this.timestampToTime(_this.dialogList.taskendtime);
                _this.dialogList.reviewtime = _this.timestampToTime(_this.dialogList.reviewtime);


                this.$http({
                    url: url,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                    data: _this.dialogList,
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.isDialog = false;
                        _this.getData();
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },

            //过程状态信息
            getProcessStateSelectUserData() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/operation/qxCleandetail/selectUser?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.processStateSelectUserData = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            getProcessStateData() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/operation/qxCleandetail/selectByTid/' + _this.dialogList.tid + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.processStateData = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            insertProcessStateList() {
                this.isProcessStateDialog = true;
                this.dialogProcessStateTitle = '添加';
                this.dialogProcessStateList = {
                    elecmeter: '',
                    atoperator: '',
                    batchnums: '',
                    beginaddtime: '',
                    begintime: '',
                    customer: '',
                    detailname: '',
                    did: '',
                    endtime: '',
                    exceptionboxnums: '',
                    exceptionnums: '',
                    exceptionunit: '',
                    needboxnums: '',
                    needer: '',
                    neednums: '',
                    needunit: '',
                    overaddtime: '',
                    planboxnums: '',
                    plannums: '',
                    planunit: '',
                    starttime: '',
                    type: '',
                    typeName: '',
                    tid: this.dialogList.tid,
                };
            },
            updateProcessStateList(row) {
                this.isProcessStateDialog = true;
                this.dialogProcessStateTitle = '编辑';
                this.dialogProcessStateList = row;
                this.dialogProcessStateList.typeName = parseInt(this.dialogProcessStateList.typeName);
                this.dialogProcessStateList.neednums = this.dialogProcessStateList.neednums+'';
                this.dialogProcessStateList.needunit = this.dialogProcessStateList.needunit+'';
                this.dialogProcessStateList.exceptionboxnums = this.dialogProcessStateList.exceptionboxnums+'';
            },
            submitProcessStateList() {
                let _this = this;
                let url;
                if (_this.dialogProcessStateTitle === '添加') {
                    url = '/api/adscm/operation/qxCleandetail/insert?tokenId=' + _this.tokenId;
                } else if (_this.dialogProcessStateTitle === '编辑') {
                    url = '/api/adscm/operation/qxCleandetail/update?tokenId=' + _this.tokenId;
                }


                this.dialogProcessStateList.customer = this.timestampToTime(this.dialogProcessStateList.customer);
                this.dialogProcessStateList.begintime = this.timestampToTime(this.dialogProcessStateList.begintime);
                this.dialogProcessStateList.exceptionnums = this.timestampToTime(this.dialogProcessStateList.exceptionnums);
                this.dialogProcessStateList.exceptionunit = this.timestampToTime(this.dialogProcessStateList.exceptionunit);
                this.dialogProcessStateList.starttime = this.timestampToTime(this.dialogProcessStateList.starttime);
                this.dialogProcessStateList.endtime = this.timestampToTime(this.dialogProcessStateList.endtime);

                this.$http({
                    url: url,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                    data: _this.dialogProcessStateList,
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.isProcessStateDialog = false;
                        if (_this.dialogProcessStateTitle === '添加') _this.getProcessStateData();

                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },

            //备注记录信息
            getNotesRecordData() {
                let _this = this;
                this.$http({
                    url: _this.dialogNotesRecordURL.getURL + _this.dialogList.tid + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {

                    if (res.data.statusCode == 200) {
                        _this.notesRecordData = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            insertNotesRecordList() {
                this.isNotesRecordDialog = true;
                this.dialogNotesRecordTitle = '添加';
                this.dialogNotesRecordList = {
                    content: '',
                    id: '',
                    object: '',
                    person: '',
                    personName: '',
                    time: '',
                    type: '',
                    tid: this.dialogList.tid,
                };
            },
            updateNotesRecordList(row) {
                this.isNotesRecordDialog = true;
                this.dialogNotesRecordTitle = '编辑';
                this.dialogNotesRecordList = row;
            },
            submitNotesRecordList() {
                let _this = this;
                let url;
                if (_this.dialogNotesRecordTitle === '添加') {
                    url = _this.dialogNotesRecordURL.insertURL + '?tokenId=' + _this.tokenId;
                } else if (_this.dialogNotesRecordTitle === '编辑') {
                    url = _this.dialogNotesRecordURL.updateURL + '?tokenId=' + _this.tokenId;
                }
                this.$http({
                    url: url,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                    data: _this.dialogNotesRecordList,
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.isNotesRecordDialog = false;
                        if (_this.dialogNotesRecordTitle === '添加') _this.getNotesRecordData();
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            handleClick(tab, event) {
                if (tab.name === '2') {
                    this.getProcessStateSelectUserData();
                    this.getProcessStateData();
                } else if (tab.name === '3') {
                    this.getNotesRecordData();
                }

            },
            handleSizeChange: function (size) {
                this.pagesize = size;
            },
            handleCurrentChange: function (currentPage) {
                this.currentPage = currentPage;
            },
            timestampToTime(timestamp) {
                if (timestamp) {
                    let date = new Date(timestamp);
                    let Y = date.getFullYear() + '-';
                    let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
                    let D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + " ";
                    let h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ":";
                    let m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ":";
                    return timestamp ? Y + M + D + h + m + '00' : '';
                } else {
                    return '';
                }
            },
        }
    }
</script>

<style scoped>

    #parts .el-table--small {
        font-size: 13px;
    }

    #parts .el-table .cell,
    #parts .el-table th div {
        padding-left: 0;
        padding-right: 0;
    }

    #parts .el-tab-pane.dialog1 .el-form {
        margin-bottom: 30px;
    }

</style>
